layui.config({
	base : "js/"
}).use(['form','layer','jquery','laypage'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		laypage = layui.laypage,
		$ = layui.jquery;

	
	//添加友情链接
	$(".linksAdd_btn").click(function(){
		layui.layer.open({
			title : "添加网关",
			type : 2,
			content : "/admin/gateway/create",
			 area: ['45em', '45em'],
			 
			success : function(layero, index){
				// layui.layer.tips('点击此处返回文章列表', '.layui-layer-setwin .layui-layer-close', {
				// 	tips: 3
				// });
				} 
			})
		// })	
	})
         
	          // 通知
	form.on("switch(isShow)",function(data){
		if(data.elem.checked){
			var state = 1;
		}else{
			var state = 0;
		}
		
        $.ajax({
            type:'post',
            url:'/admin/gateway/status',
            async:false, 
            data:{
                '_token':$('input[name=_token]').val(),
                'id':$(this).attr('key'),
                'status':state
            },

            dataType:'json',
            success:function (data) {
                if(data.status == 1){

                    top.layer.msg("修改成功！",{time:800});
                    
                    //刷新父页面
                    // parent.location.reload();
                }else{
                    
                    top.layer.msg("修改失败！",{time:800});
                }
            }
        })
        return false;
})
});


